package utils

import (
	"github.com/gin-gonic/gin"
	"io"
	"log"
	"os"
)

var Logger *log.Logger

func init() {
	// 日志相关
	// gin.DisableConsoleColor()
	f, _ := os.Create("./logs/gin.log")
	// f, _ := os.Create(conf.Config.File.Log)
	// gin.DefaultWriter = io.MultiWriter(f)
	gin.DefaultWriter = io.MultiWriter(f, os.Stdout)
	Logger = log.New(f, "INFO ", log.Ldate|log.Ltime|log.Lshortfile)
}

// for logging
func Info(args ...interface{}) {
	Logger.SetPrefix("INFO ")
	Logger.Println(args...)
}

func Danger(args ...interface{}) {
	Logger.SetPrefix("ERROR ")
	Logger.Println(args...)
}

func Warning(args ...interface{}) {
	Logger.SetPrefix("WARNING ")
	Logger.Println(args...)
}
